package com.cyss.greenball.util;

import org.apache.http.message.BasicNameValuePair;

import android.util.Log;

import com.lianzt.commondata.AbstractCommonData;
import com.lianzt.commondata.DataConvertFactory;
import com.lianzt.util.SSLConnection;

public class SystemUtil {
	public static int SCREEN_WIDTH;
	public static int SCREEN_HEIGHT;
	public static int RATE = 10;
	public static float TIMESTEP = 1.0f / 60.0f;
	public static int ITERATIONS = 10;
	public static float GREEN_BALL_RADIUS;
	public static int GAME_STATE_SUCCESS = 12;
	public static int GAME_STATE_FAIL = 13;
	public static String LOG_TAG = "cyss_green_ball";
	public static final int GAME_ELEMENT_GREENBALL = 30;
	public static final int GAME_ELEMENT_LINEBARRIER = 31;
	public static final int GAME_ELEMENT_RECTANGLEBARRIER = 32;
	public static final int GAME_ELEMENT_TRAPHOLE = 33;
	public static final int GAME_ELEMENT_DESTINYHOLE = 34;
	public static final int GAME_ELEMENT_HOLE = 35;
	public static final int GAME_ELEMENT_REVOKE = 36;
	public static final int GAME_MAP_SAVE = 37;
	public static final int GAME_TRY_PLAY = 38;
	private static final String SERVER_URL = "http://192.168.1.36:8084/GreenBallServer/ClientServlet";
	public static final String SUBMIT_GREENBALL_MAP = "M001";
	public static final String GET_GREENBALL_MAP = "M002";
	
	public static AbstractCommonData getEmptyGameInstance(){
		AbstractCommonData acd = DataConvertFactory.getInstanceEmpty();
		//acd.putArrayValue("", );
		return acd;
	}
	
	public static AbstractCommonData getSendInstance(String serviceCode){
		AbstractCommonData acd = DataConvertFactory.getInstance();
		acd.getDataValue("head").putStringValue("service_code", serviceCode);
		return acd;
	}
	
	public static AbstractCommonData sendCommonData(AbstractCommonData acd){
		String sendData = DataConvertFactory.praseString(acd);
		Log.d("<<<<<", acd.toString());
		BasicNameValuePair xml = new BasicNameValuePair("xml", sendData);
		AbstractCommonData back_acd = null;
		try {
			back_acd = SSLConnection.sendHttpPost(SERVER_URL, xml);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return back_acd;
	}
}
